package com.jy.admin.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.StringUtils;
import com.jy.admin.db.dao.BogLogDao;
import com.jy.admin.db.entity.BogLogEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: anonymous
 * Date: 2021-12-22
 * Time: 15:59:52.819
 */

@Repository
public class BogLogDaoImpl extends AbstractBaseMapper<BogLogEntity> implements BogLogDao {

    @Override
    public void updateStatusByTelMsgId(String telMsgId, Integer status) {
        Map<String, Object> params = new HashMap<>();
        params.put("telMsgId", telMsgId);
        params.put("status", status);
        getSqlSession().update(this.getStatement("updateStatusByTelMsgId"), params);
    }

    @Override
    public BogLogEntity selectByTelMsgId(String telMsgId) {
        Map<String, Object> params = new HashMap<>();
        params.put("telMsgId", telMsgId);
        return getSqlSession().selectOne(this.getStatement("selectByTelMsgId"), params);
    }

    @Override
    public BogLogEntity selectById(Integer id) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        return getSqlSession().selectOne(this.getStatement("selectById"), params);
    }

    @Override
    public List<BogLogEntity> getReplyList(String robotId) {
        Map<String, Object> params = new HashMap<>();
        params.put("robotId", robotId);
        return getSqlSession().selectList(this.getStatement("getReplyList"), params);
    }

    @Override
    public List<BogLogEntity> getListByDateAndOrderNo(String date, String orderNo, Integer replyStatus,String productName) {
        Map<String, Object> params = new HashMap<>();
        params.put("date", date);
        params.put("productName", productName);
        if (!StringUtils.isEmpty(orderNo)) {
            params.put("orderNo", "%" + orderNo + "%");
        } else {
            params.put("orderNo", null);
        }


        params.put("replyStatus", replyStatus);
        return getSqlSession().selectList(this.getStatement("getListByDateAndOrderNo"), params);
    }

    @Override
    public List<BogLogEntity> getListBySendStatus(Integer sendStatus) {
        Map<String, Object> params = new HashMap<>();
        params.put("sendStatus", sendStatus);
        return getSqlSession().selectList(this.getStatement("getListBySendStatus"), params);
    }
}